package com.xyy.saas.payment.service.impl;

import com.xyy.saas.payment.dao.mapper.BankBillJd0026Mapper;
import com.xyy.saas.payment.dao.model.BankBillJd0026;
import com.xyy.saas.payment.dao.model.BankBillJd0026QueryParam;
import com.xyy.saas.payment.dao.model.BankBillJd0028;
import com.xyy.saas.payment.service.BankBillJd0026Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 新分账商户根据交易结算信息生成结算表-shareAccountWater(BankBillJd0026)表服务实现类
 *
 * @author chujian
 * @since 2023-06-13 14:38:10
 */
@Slf4j
@Service
public class BankBillJd0026ServiceImpl implements BankBillJd0026Service {
    @Resource
    private BankBillJd0026Mapper bankBillJd0026Mapper;
    @Override
    public List<BankBillJd0026> queryIncompleteBill(Date billDate) {
        return bankBillJd0026Mapper.queryIncompleteBill(billDate);
    }
    public int updateBatch(List<BankBillJd0026> entities) {
        if (CollectionUtils.isEmpty(entities)) {
            return 0;
        }
        return bankBillJd0026Mapper.updateBatch(entities);
    }
    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public BankBillJd0026 queryById(Long id) {
        return this.bankBillJd0026Mapper.queryById(id);
    }

    /**
     * 查询总数
     * @param param 查询条件
     * @return
     */
    @Override
    public long total(BankBillJd0026QueryParam param) {
        if (null == param) {
            param = new BankBillJd0026QueryParam();
        }
        if (!StringUtils.isEmpty(param.getSettleFinishTimeEnd()) && param.getSettleFinishTimeEnd().trim().length() <= 10) {
            param.setSettleFinishTimeEnd(param.getSettleFinishTimeEnd().trim() + " 23:59:59");
        }
        return bankBillJd0026Mapper.total(param);
    }

    /**
     * 查询指定行数据
     *
     * @param param 查询条件
     * @return 对象列表
     */
    @Override
    public List<BankBillJd0026> queryPage(BankBillJd0026QueryParam param) {
        if (null == param) {
            param = new BankBillJd0026QueryParam();
        }
        if (!StringUtils.isEmpty(param.getSettleFinishTimeEnd()) && param.getSettleFinishTimeEnd().trim().length() <= 10) {
            param.setSettleFinishTimeEnd(param.getSettleFinishTimeEnd().trim() + " 23:59:59");
        }
        param.setOffset(((param.getPage() == 0 ? 1 : param.getPage()) - 1) * param.getPageSize());
        return bankBillJd0026Mapper.queryPageV2(param);
    }

    /**
     * 查询指定行数据
     *
     * @param param 查询条件
     * @return 对象列表
     */
    @Override
    public List<BankBillJd0026> queryExport(BankBillJd0026QueryParam param) {
        if (null == param) {
            param = new BankBillJd0026QueryParam();
        }
        if (!StringUtils.isEmpty(param.getSettleFinishTimeEnd()) && param.getSettleFinishTimeEnd().trim().length() <= 10) {
            param.setSettleFinishTimeEnd(param.getSettleFinishTimeEnd().trim() + " 23:59:59");
        }
        return bankBillJd0026Mapper.queryExport(param);
    }

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<BankBillJd0026> 实例对象列表
     * @return 影响行数
     */
    @Override
    public int insertBatch(List<Object> entities) {
        if (CollectionUtils.isEmpty(entities)) {
            return 0;
        }
        return bankBillJd0026Mapper.insertBatch(entities);
    }

    /**
     * 通过主键删除数据
     *
     * @param bankBillJd0026 实例对象
     * @return 影响行数
     */
    @Override
    public int delete(BankBillJd0026 bankBillJd0026) {
        return bankBillJd0026Mapper.delete(bankBillJd0026);
    }
    
}
